﻿'Hecho por Antonella Canto
Imports System.Data
Imports System.Data.Odbc
Imports System.Data.OleDb
Imports System.Data.SqlClient

Public Class Datos_repartidores
    Public cn As OdbcConnection
    Public con As SqlConnection
    Function AltaRepartidor(ByVal nodo As Entidades.Encapsuladora_repartidores) As Boolean
        Try
            Try
                Dim cmd As OdbcCommand = New OdbcCommand("{call Alta_repartidor (?,?,?,?)}", cn)
                cmd.CommandType = CommandType.StoredProcedure
                cmd.Parameters.AddWithValue("@nc", nodo.R)
                cmd.Parameters.AddWithValue("@ci", nodo.R1)
                cmd.Parameters.AddWithValue("@fn", nodo.R2)
                cmd.Parameters.AddWithValue("@dir", nodo.R3)

                cn.Open()
                cmd.ExecuteNonQuery()

            Catch o As OdbcException
                MsgBox(o.Message.ToString)
                Return False
            Finally
                cn.Close()
            End Try
            Return True

        Catch ex As Exception


        End Try
        Return False

    End Function
    Function BajaRepartidor(ByVal nodo As Entidades.Encapsuladora_repartidores) As Boolean
        Try
            Try
                Dim cmd As OdbcCommand = New OdbcCommand("{call baja_repartidor (?)}", cn)
                cmd.CommandType = CommandType.StoredProcedure
                cmd.Parameters.AddWithValue("@id", nodo.R4)

                cn.Open()
                cmd.ExecuteNonQuery()

            Catch o As OdbcException
                MsgBox(o.Message.ToString)
                Return False
            Finally
                cn.Close()
            End Try
            Return True

        Catch ex As Exception


        End Try
        Return False

    End Function
    Function ModificacionRepartidor(ByVal nodo As Entidades.Encapsuladora_repartidores) As Boolean
        Try
            Try
                Dim cmd As OdbcCommand = New OdbcCommand("{call modificacion_repartidor (?,?,?,?)}", cn)
                cmd.CommandType = CommandType.StoredProcedure
                cmd.Parameters.AddWithValue("@nc", nodo.R)
                cmd.Parameters.AddWithValue("@ci", nodo.R1)
                cmd.Parameters.AddWithValue("@fn", nodo.R2)
                cmd.Parameters.AddWithValue("@dir", nodo.R3)
                cn.Open()
                cmd.ExecuteNonQuery()

            Catch o As OdbcException
                MsgBox(o.Message.ToString)
                Return False
            Finally
                cn.Close()
            End Try
            Return True

        Catch ex As Exception


        End Try
        Return False

    End Function
    Function consultarepartidor() As DataSet

        Dim conn As SqlConnection = Nothing

        Dim ds As New DataSet

        Dim rdr As SqlDataReader = Nothing


        Try
            Dim cmd As SqlCommand = New SqlCommand("{call consulta_producto ()}", con)

            cmd.CommandType = CommandType.StoredProcedure


            Dim dap As New SqlDataAdapter
            dap.SelectCommand = cmd
            dap.Fill(ds)


            Return ds


        Catch ex As Exception
            MsgBox(ex.ToString)
            Return ds

        End Try
    End Function
End Class